<template>
  <form-create
          v-model="fapi"
          :rule="rule"
          :option="option"
          @submit="onSubmit"
  ></form-create>
</template>

<script>
  import formCreate from "@form-create/element-ui";

  export default {
    data () {
      return {
        fapi: null,
        rule:[
          {
            "type": "FcRow",
            children: [
              {
                "type": "col",
                "props": {
                  "span": 12
                },
                "children": [
                  {
                    "type": "input",
                    "field": "queryDate",
                    "title": "日期",
                    "info": "",
                    "_fc_drag_tag": "input",
                    "hidden": false,
                    "display": true
                  }
                ],
                "_fc_drag_tag": "col",
                "hidden": false,
                "display": true
              },
              {
                "type": "col",
                "props": {
                  "span": 12,
                  "offset": 0,
                  "push": 7,
                  "pull": 0
                },
                "children": [
                  {
                    "type": "el-button",
                    "props": {
                      "size": "small"
                    },
                    "children": [
                      "查询"
                    ],
                    on:{
                      click:()=>{
                        console.log(this.fapi)
                        console.log(`query: "${this.fapi.getValue('queryDate')}"`)
                        this.fapi.trigger('elTable','loadData',{'name':'zhang3'})
                      }
                    },
                    "_fc_drag_tag": "el-button",
                    "hidden": false,
                    "display": true
                  }
                ],
                "_fc_drag_tag": "col",
                "hidden": false,
                "display": true
              }
            ],
            "_fc_drag_tag": "row",
            "hidden": false,
            "display": true
          },
          {
            type: "elTable",
            field: "elTable",
            props: {
              "_optionType": 1,
              data:[
              ],
            },
            on:{
              loadData:(param)=>{
                console.log('loadData')
                console.log(param)
                const data = [
                  {
                    "name":"nammeaa",
                    "address":"adddd"
                  }
                ]
                const vm = this.fapi.el('elTable')
                const formCreateInject = vm.formCreateInject
                formCreateInject.prop.props.data = data
              }
            },
            header: [
              {
                "prop": "date",
                "label": "日期",
                "width": "160"
              },
              {
                "prop": "name",
                "label": "姓名",
                "width": "160"
              },
              {
                "prop": "address",
                "label": "地址",
                "width": "260"
              },
              {
                "prop": "",
                "label": "操作",
                "width": "160",
                "fixed": "right",
                "buttons": [
                  {
                    "name": "编辑"
                  },
                  {
                    "name": "删除"
                  }
                ]
              }
            ],
            "_fc_drag_tag": "elTable",
            "hidden": false,
            "display": true,
            "effect": {
              /*"fetch": {
                "to": "props.data",
                "action": "http://localhost:19900/flow/coding/dynamicTaskflow/executeTask",
                "method": "POST",
                "dataType": "json",
                "data": {
                  "taskFlowId": 9
                },
                "headers": {},
                "parse": function (res){   return res.obj;},
              }*/
            }
          },
          {
            "type": "elPagination",
            "field": "s6zg6zfcrjna3",
            "title": "",
            "info": "",
            "_fc_drag_tag": "elPagination",
            "hidden": false,
            "display": true
          }
        ],
        option:{
          "form": {
            "inline": false,
                    "labelPosition": "left",
                    "size": "small",
                    "labelWidth": "125px",
                    "hideRequiredAsterisk": false,
                    "showMessage": true,
                    "inlineMessage": false
          },
          "submitBtn": true,
          onSubmit:(formData)=>{
            console.log(this.fApi.getValue('wggg6zfd1aqy4'))
            console.log(`query: "${this.fApi.getValue('wggg6zfd1aqy4')}"`)
            // alert(JSON.stringify(formData))
          }
      }
      }
    },
    methods: {
      mm() {
        console.log('sdddddd')
      },
      onSubmit (formData) {
        //todo 提交表单
      }
    }
  }
</script>